
#pragma once
#include "ShaderBuffer.h"

class ShaderElementData
{
public:
	PROPERTY(GLvoid *, m_data, Data);
	PROPERTY(GLsizeiptr, m_size, DataSize);
};
typedef std::shared_ptr<ShaderElementData> ShaderElementDataPtr;

#define CREATE_SHADER_ELEMENT_DATA(varName, dataset)\
	auto varName = std::make_shared<ShaderElementData>(); \
	varName->setData((GLvoid *)dataset);	\
	varName->setDataSize((GLsizeiptr)sizeof(dataset))

class ShaderElementBuffer : public ShaderBuffer
{
public:
	ShaderElementBuffer(ShaderElementDataPtr pElementData, ShaderVertexDataPtr pVertexData);
	virtual ~ShaderElementBuffer() = default;

public:
	virtual void initBinding();
	virtual void cleanBinding();

public:
	virtual void draw(GLuint vertexSize, GLuint vertexIndex = 0);

private:
	GLuint m_veo;
	ShaderElementDataPtr m_pElementData;

public:
	static ShaderVertexPtr create(ShaderElementDataPtr pElementData, ShaderVertexDataPtr pVertexData)
	{
		auto shader = std::make_shared<ShaderElementBuffer>(pElementData, pVertexData);
		shader->init();
		return shader->isValid() ? shader : nullptr;
	}
};